package com.xmmj.main.view.dialog

import android.os.Bundle
import android.view.View
import android.view.WindowManager
import com.xmmj.baselibrary.base.dialog.BaseMvvmDialog
import com.xmmj.baselibrary.utils.Display
import com.xmmj.main.viewmodel.PrivacyViewModel
import com.xmmj.module_main.BR
import com.xmmj.module_main.R
import com.xmmj.module_main.databinding.DialogPrivacyBinding

/**
 * 隐私协议对话框
 */
class PrivacyDialog : BaseMvvmDialog<DialogPrivacyBinding, PrivacyViewModel>() {
    private var onConfirmCallback: ((PrivacyDialog) -> Unit)? = null

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mDataBinding.tvComfirm.setOnClickListener {
            onConfirmCallback?.invoke(this)
            dismiss()
        }
    }

    override fun getVariableId(): Int {
        return BR.viewModel
    }

    override fun getLayoutId(): Int {
        return R.layout.dialog_privacy
    }

    override fun getWidth(): Float {
        return (Display.getScreenW(requireContext()) * 4 / 5).toFloat()
    }

    override fun getHeight(): Float {
        return WindowManager.LayoutParams.WRAP_CONTENT.toFloat()
    }

    override fun isCancelable(): Boolean {
        return false
    }

    fun setOnConfirmCallback(onConfirmCallback: (PrivacyDialog) -> Unit): PrivacyDialog {
        this.onConfirmCallback = onConfirmCallback
        return this
    }
}